<#--  tabindex="-1"  必须有 editable select2 支持-->
<div class="modal fade " id="editScoreModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document" style="width:75%">
        <div class="box box-info">
            <div class="box-header with-border">
                <h3 class="box-title">指标录入</h3>
                <button type="button" class="btn btn-danger pull-right" data-dismiss="modal">关闭</button>
            </div>
            <!-- /.box-header -->
            <!-- form start -->
            <form class="form-horizontal">
                <div class="box-body">
                    <table id="editQuotaTable" data-toggle="table" data-url="#"  data-search="true"
                           data-unique-id="id"
                           data-query-params="editQuotaTableQueryParams">
                        <thead>
                        <tr>
                            <th data-field="index" data-formatter="indexFormatter">序号</th>
                            <th data-field="modelDimensionName">评价维度</th>
                            <th data-field="quotaName" data-formatter="quotaNameFormatter">具体指标</th>
                            <th data-field="editorStr"  data-align="center">指标值</th>
                            <th data-field="score">分数</th>
                        </tr>
                        </thead>
                    </table>
                </div>
                <!-- /.box-body -->
                <div class="box-footer">
                    <input type="hidden" id="modelCustScoreId">
                    <button type="button" class="btn btn-default pull-right" data-dismiss="modal">完成</button>
                </div>
                <!-- /.box-footer -->
            </form>
        </div>
    </div>
</div>
<script>

    function quotaNameFormatter(value, row, index){
        if(row.description == "" || row.description == null) {
            return value;
        }
        return "<a href=\"#\" data-toggle=\"tooltip\" title=\""+row.description+"\">"+value+"</a>"
    }
    function editQuotaTableQueryParams() {
        return {
            scoreId: $("#modelCustScoreId").val()
        };
    }

    function editScoreModalInit(custScoreId) {
        $("#modelCustScoreId").val(custScoreId);
        $("#editQuotaTable").bootstrapTable("refresh", {url: "/custscore/detailInfo/list"});
    }
    function modifyCustValue( id, newValue) {
        var $table = $("#editQuotaTable"  );
        var data = {
            detailId: id,
            value: newValue
        };
        var url = "/custscore/detail/modify";
        postReq(url, data, function (result) {
            if (result.success) {
                var url1 = "/custscore/detail/"+id;
                getReq(url1, function (result1) {
                    var row = $table.bootstrapTable("getRowByUniqueId", id);
                    row.score = result1.score;
                    row.editorStr = result1.editorStr;
                    $table.bootstrapTable('updateByUniqueId', {id: id, row: row});
                    $("#custScoreTable").bootstrapTable("refresh");
                    toastr['success']('更新成功', '提示');
                });
            } else {
                toastr['error'](result.msg, '提示');
            }
        });
    }
</script>